import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

public class Text {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.As();

        System.out.println("===============");
        Cat cat = new Cat("xiaoming");
        cat.B();
        cat.C();



    }
}
class Dog{  //父类
    public int a = 10;
    public int b = 11;
    public int c = 12;
    public Dog(){
        this.a = 30;   //构造方法是用来初始化对象的
        this.b = 31;
        this.c = 32;
    }
    public void As(){
        System.out.println(this.a);  //打印构造方法
        System.out.println(this.b);
        System.out.println(this.c);
    }
    public String name;
    public Dog( String name){
        this.name = name;
    }



}
class Cat extends Dog{   //子类
    public int a =  21;
    public int d = 22;
    public int e = 8;
    public void B(){
        System.out.println(this.a);
        System.out.println(super.a);
        System.out.println(b);   //父类与子类变量名相同时优先访问的是子类的值
        System.out.println(c);  //要想访问父类就要加入super关键字
        System.out.println(d);
    }
    public void C(){
        System.out.println(this.e);
//        System.out.println(super.name);
    }
    public Cat(String name){
        super(name); // 要么就地初始化要么构造方法
        System.out.println(name);
    }
}
